﻿using GPM;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LF3.Controllers;
using LF3.Moduls;
using CP.Utility;

namespace LF3Proj
{
    public partial class FrmHeatAnnounce : BaseForm
    {
        LF_SchedulerController schedulerController = new LF_SchedulerController();
        public FrmHeatAnnounce()
        {
            InitializeComponent();
        }

        private void btnAnnouceStart_Click(object sender, EventArgs e)
        {
            Lf_Schedule schedule = this.gvSteelPlan.GetFocusedRow() as Lf_Schedule;
            if (schedule == null)
            {
                ExMessageBox.Show("提示信息：未选中一条记录，不能通报！", AppSetter.SoftName);
                return;
            }
            if (ExMessageBox.Confirm("确定要炉次通报吗？", AppSetter.SoftName) != DialogResult.Yes)
                return;
            string msg = schedulerController.HeatAnnounce(schedule);
            RefreshPlans();
            if (string.IsNullOrEmpty(msg))
            {
                ExMessageBox.Show("提示信息：炉次通报成功！", AppSetter.SoftName);
                LogHelper.Log("炉次通报", "新增", "炉次通报", schedule.bofscheduleid.ToString(), schedule.heatid);
            }
            else
                ExMessageBox.Show("提示信息：炉次通报失败！错误信息：" + msg, AppSetter.SoftName);
            this.Close();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            RefreshPlans();
        }

        private void FrmHeatAnnounce_Load(object sender, EventArgs e)
        {
            RefreshPlans();
        }

        private void RefreshPlans()
        {
            gcSteelPlan.DataSource = schedulerController.GetNotStartSchedulers();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
